package cn.com.ddapp.ddm.fragment.base;

import android.content.Intent;
import android.graphics.Paint;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ExpandableListAdapter;
import android.widget.ExpandableListView;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.bumptech.glide.Glide;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import butterknife.BindView;
import cn.com.ddapp.ddm.AppConfig;
import cn.com.ddapp.ddm.MainActivity;
import cn.com.ddapp.ddm.R;
import cn.com.ddapp.ddm.api.OKUtilAPI;
import cn.com.ddapp.ddm.base.BaseApplication;
import cn.com.ddapp.ddm.bean.settleShopcar.SettleAccountsEntity;
import cn.com.ddapp.ddm.bean.shopcar.GoodsCar;
import cn.com.ddapp.ddm.bean.shopcar.Shopcar;
import cn.com.ddapp.ddm.bean.shopcar.ShopcarEntity;
import cn.com.ddapp.ddm.inter.OkUtilCallback;
import cn.com.ddapp.ddm.ui.empty.EmptyLayout;
import cn.com.ddapp.ddm.ui.order.OrderSureActivity;
import cn.com.ddapp.ddm.ui.shopcar.ShopcarEditActivity;
import cn.com.ddapp.ddm.util.SPUtils;
import cn.com.ddapp.ddm.util.TDevice;
import cn.com.ddapp.ddm.util.TLog;
import okhttp3.Call;

/**
 * Created by Administrator on 2016/7/20 0020.
 */
public class ShopCatFragment extends BaseFragment implements View.OnClickListener{

    @BindView(R.id.title)
    TextView title;

    @BindView(R.id.action)
    TextView action;

    @BindView(R.id.listView)
    ExpandableListView listView;
    @BindView(R.id.error_layout)
    EmptyLayout mEmptyLayout;

    @BindView(R.id.balanceCheckBox)
    CheckBox mBalanceCheckBox;

    @BindView(R.id.total_account)
    TextView mTotalAccount;
    @BindView(R.id.total_account_1)
    TextView mTotalAccount1;
    @BindView(R.id.balance)
    TextView mBalance;
    @BindView(R.id.nodata)
    RelativeLayout mNodata;
    @BindView(R.id.goShop)
    TextView goShop;



    private List<Shopcar> shopcars = new ArrayList<Shopcar>();// 保存一级目录的商家
    private HashMap<Object, List<GoodsCar>> goodsCarMap = new HashMap<Object, List<GoodsCar>>();// 保存二级目录的购物车

    //保存子childbox的选中状态
    private HashMap<Integer, HashMap<Integer, Boolean>> isChildSelected = new HashMap<Integer, HashMap<Integer,Boolean>>();
    //保存groupbox的选中状态
    private HashMap<Integer, Boolean> isGroupSelected = new HashMap<Integer, Boolean>();
    private List<GoodsCar> mgoodsList = new ArrayList<>();
    private ExpandableListView.OnGroupClickListener onGroupClickListener;
    private boolean isAuto  = false;//全选checkbox是手动点击还是自动变化 默认手动
    private int lastGroupSelectedSize = 0;
    private int lastChildSelectedSize = 0;
    private HashSet<Integer> selectedCarsId = new HashSet<>();//选中的car id集合
    Integer totalCount;

    @Override
    protected String getFragmentTag() {
        return ShopCatFragment.class.getSimpleName();
    }

    @Override
    protected void initView(View view, Bundle savedInstanceState) {
        if(!SPUtils.getBooleanData(getContext(),SPUtils.ISLOGIN)){
            return;
        }
//        if(TDevice.isTablet(BaseApplication.getIntstance())){
//            title.setVisibility(View.GONE);
//        }

//        title.setText(R.string.shop_car);
//        action.setText(R.string.edit_car);
//        action.setVisibility(View.VISIBLE);
        action.setOnClickListener(this);
        mEmptyLayout.setOnLayoutClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View view) {
                requestData();
            }
        });
        mTotalAccount.setText(0.00+"");
        mTotalAccount1.setText(AppConfig.MONEY_SYMBEL+0.00 );
        mBalance.setText(BaseApplication.getIntstance().getResources().getString(R.string.go_balance)+"(0)");

    }

    private void toInclick() {
        mBalance.setBackgroundResource(R.color.title_color);
        mBalance.setOnClickListener(this);
    }

    private void toClick() {
        mBalance.setBackgroundResource(R.color.lightest_gray1);
        mBalance.setOnClickListener(null);
    }

    @Override
    protected void initData() {

        if(!SPUtils.getBooleanData(getContext(),SPUtils.ISLOGIN)){
            return;
        }
        requestData();
    }

    @Override
    public void onClick(View v) {
        if(v.getId()==mBalance.getId()){
            for(int i=0;i<shopcars.size();i++){
                HashMap<Integer,Boolean> map = isChildSelected.get(i);
                for(int k=0;k<map.size();k++){
                    if(map.get(k)){
                        selectedCarsId.add(goodsCarMap.get(i).get(k).getShopCarId());
                    }
                }
            }
            if(selectedCarsId.size()<=0){
                BaseApplication.getIntstance().showToast(BaseApplication.getIntstance().getString(R.string.go_balance_error_zero), Toast.LENGTH_SHORT,0, Gravity.CENTER);
            }else{
                clearCarsRequest();
            }
        }else if(action.getId()==v.getId()){
            Intent intentEdit = new Intent(ShopCatFragment.this.getActivity(), ShopcarEditActivity.class);
            startActivity(intentEdit);

        }else if(v.getId()==goShop.getId()){
            MainActivity activity =(MainActivity)((ShopCatFragment.this).getActivity());
            activity.showHomePageFragment();
        }
    }

    /**
     * 去结算
     */
    private void clearCarsRequest() {

        StringBuilder ids = new StringBuilder();
        for(Integer id : selectedCarsId){
            ids.append(id+",");
        }
        if(ids.toString().length()<=0){
            BaseApplication.getIntstance().showToast(BaseApplication.getIntstance().getString(R.string.go_balance_error_zero), Toast.LENGTH_SHORT,0, Gravity.TOP);
            return;
        }

        showWaitDialog(R.string.settle_account_ing);

        String userId = SPUtils.getStringData(getActivity(), SPUtils.USERID);;
        final OkUtilCallback okUtilCallback = new OkUtilCallback(){
            @Override
            public void onMyResponse(String response, int id) {
                hideWaitDialog();
                TLog.log(getFragmentTag(),response);
                SettleAccountsEntity entity = gson.fromJson(response,SettleAccountsEntity.class);
                if((!AppConfig.RESULT_OK.equalsIgnoreCase(entity.getResult()))&&entity.getLogin()){
                    mEmptyLayout.setErrorType(EmptyLayout.NO_LOGIN);
                }else if((!AppConfig.RESULT_OK.equalsIgnoreCase(entity.getResult()))){
                    BaseApplication.getIntstance().showToast(entity.getResult(), Toast.LENGTH_SHORT,0, Gravity.TOP);
                }else if((AppConfig.RESULT_OK.equalsIgnoreCase(entity.getResult()))){
                    selectedCarsId.clear();
                    Intent intent = new Intent(getActivity(), OrderSureActivity.class);
                    //用Bundle携带数据
                    Bundle bundle=new Bundle();
                    //传递name参数为tinyphp
                    bundle.putString("response", response);
                    intent.putExtras(bundle);
                    startActivity(intent);
                }
            }
        };
        OKUtilAPI.post(OKUtilAPI.clearCars, "userId=" + userId+"&ids="+ids.substring(0,ids.length()-1)+"&addrId="+AppConfig.CITY_ID, okUtilCallback);
    }


    final ExpandableListAdapter adapter = new BaseExpandableListAdapter() {

        @Override
        public boolean isChildSelectable(int groupPosition, int childPosition) {
            return true;
        }

        @Override
        public boolean hasStableIds() {
            return true;
        }

        @Override
        public View getGroupView(final int groupPosition, boolean isExpanded,
                                 View convertView, ViewGroup parent) {
            TextView group_text;
            CheckBox group_box;
            convertView =  RelativeLayout.inflate(getActivity(), R.layout.shopcar_item_shop, null);

            convertView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    BaseApplication.getIntstance().showToast(shopcars.get(groupPosition).getShopName());
                }
            });

            group_text = (TextView) convertView.findViewById(R.id.sName);
            group_box = (CheckBox) convertView.findViewById(R.id.sCheckBox);

            group_text.setText(shopcars.get(groupPosition).getShopName());
            group_box.setChecked(isGroupSelected.get(Integer.valueOf(groupPosition)));

            group_box.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    isGroupSelected.put(Integer.valueOf(groupPosition), isChecked);
                    autoChangeChildCheckeState(isChecked,groupPosition);
                }
            });
            return convertView;
        }

        @Override
        public long getGroupId(int groupPosition) {
            // TODO Auto-generated method stub
            return groupPosition;
        }

        @Override
        public int getGroupCount() {
            return shopcars.size();
        }

        @Override
        public Object getGroup(int groupPosition) {
            return shopcars.get(groupPosition).getShopName();
        }

        @Override
        public int getChildrenCount(int groupPosition) {
            return goodsCarMap.get(groupPosition).size();
        }

        @Override
        public View getChildView(final int groupPosition, final int childPosition,
                                 boolean isLastChild, View convertView, ViewGroup parent) {
            try {

            convertView = RelativeLayout.inflate(
                    getActivity(), R.layout.shopcar_item_car, null);
            ViewHolder holder = new ViewHolder(convertView);
            holder.gName.setText(goodsCarMap.get(groupPosition).get(childPosition).getGoodsName());
//            holder.citySize.setText(StringUtils.getDouble((cityMap.get(groupPosition).get(childPosition).getSize())/(1024 * 1024f), 2) + "MB");
            holder.gCheckBox.setChecked(isChildSelected.get(Integer.valueOf(groupPosition)).get(Integer.valueOf(childPosition)));
            holder.gAttr.setText(goodsCarMap.get(groupPosition).get(childPosition).getAttrName());
            holder.gPrice.setText(new DecimalFormat("######0.00").format(goodsCarMap.get(groupPosition).get(childPosition).getPrice()));
            holder.gNum.setText(goodsCarMap.get(groupPosition).get(childPosition).getNum()+"");


            String []nUrl=goodsCarMap.get(groupPosition).get(childPosition).getGoodsImg().split("\\.");
            StringBuffer buffer=new StringBuffer();
            buffer.append(nUrl[0]).append("_360.").append(nUrl[1]);
            Glide.with(ShopCatFragment.this.getActivity()).load(OKUtilAPI.imgBaseUrl+buffer).into(holder.gLogo);

            holder.gCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    HashMap<Integer, Boolean> map = isChildSelected.get(Integer.valueOf(groupPosition));
                    map.put(Integer.valueOf(childPosition), isChecked);
                    isChildSelected.put(Integer.valueOf(groupPosition),map);
                    //改变group的checkbox状态
                    autoChangeGroupCheckeState(isChildSelected,groupPosition,isChecked);
                }

            });
            }catch (Exception e){
                e.printStackTrace();
            }
            return convertView;
        }

        class ViewHolder {
            TextView gNum;
            TextView gPrice;
            TextView gName;
            TextView gAttr;
            CheckBox gCheckBox;
            ImageView gLogo;

            public ViewHolder(View view) {
                gNum = (TextView) view.findViewById(R.id.gNum);
                gCheckBox = (CheckBox) view.findViewById(R.id.gCheckBox);
                gLogo = (ImageView) view.findViewById(R.id.gLogo);
                gName = (TextView) view.findViewById(R.id.gName);
                gAttr = (TextView) view.findViewById(R.id.gAttr);
                gPrice = (TextView) view.findViewById(R.id.gPrice);
            }
        }

        @Override
        public long getChildId(int groupPosition, int childPosition) {
            // TODO Auto-generated method stub
            return childPosition;
        }

        @Override
        public Object getChild(int groupPosition, int childPosition) {
            return goodsCarMap.get(groupPosition).get(childPosition).getShopName();
        }
    };




    //改变child checkbox的状态
    private void autoChangeChildCheckeState(boolean isChecked,int groupPosition) {

        HashMap<Integer, Boolean> map = isChildSelected.get(groupPosition);
        for(int i=0;i<map.size();i++){
            map.put(Integer.valueOf(i), isChecked);
        }
        isChildSelected.put(Integer.valueOf(groupPosition), map);
        calcItemsAndSize();



        boolean isAllSelect = true;//默认全部选中
        int count = 0;
        for(int i=0;i<shopcars.size();i++){
            if(isGroupSelected.get(i)){
                count++;
            }
        }
        for(int i=0;i<shopcars.size();i++){
            if(!isGroupSelected.get(i)){
                isAllSelect = false;
                break;
            }
        }
        if(lastGroupSelectedSize-count==1&&lastGroupSelectedSize==isGroupSelected.size()){
            isAuto = true;//从全选到去掉一个
        }
        lastGroupSelectedSize = count;

        mBalanceCheckBox.setChecked(isAllSelect);

    }

    //获取某组下的子child的选中个数
    private int getPositionCheckedNum(HashMap<Integer, HashMap<Integer, Boolean>> map,Integer position){
        int count=0;
        HashMap<Integer, Boolean> map1 = map.get(position);
        for(int i=0;i<map1.size();i++){
            if(map1.get(i)){
                count++;
            }
        }
        return count;
    }

    //group checkbox的状态
    private void autoChangeGroupCheckeState(HashMap<Integer, HashMap<Integer, Boolean>> isChildSelected,int groupPosition, boolean isChecked) {
//        Boolean currentSelected = isGroupSelected.get(groupPosition);
        int childSelectedCount = getPositionCheckedNum(isChildSelected, groupPosition);
        if(isChecked&&(childSelectedCount==isChildSelected.get(groupPosition).size())){
            isGroupSelected.put(Integer.valueOf(groupPosition), true);
//			((BaseExpandableListAdapter)adapter).notifyDataSetInvalidated();
        }else if((!isChecked)&&(childSelectedCount==isChildSelected.get(groupPosition).size()-1)){
            isGroupSelected.put(Integer.valueOf(groupPosition), false);
//			((BaseExpandableListAdapter)adapter).notifyDataSetInvalidated();
//			calcItemsAndSize();
        }
        calcItemsAndSize();

//        Boolean chanedSelected = isGroupSelected.get(groupPosition);;
//        if(!currentSelected.toString().equalsIgnoreCase(chanedSelected.toString())){
//            isAuto = true;//自动变化
//        }


        boolean isAllSelect = true;//默认全部选中
        int count = 0;
        for(int i=0;i<shopcars.size();i++){
            if(isGroupSelected.get(i)){
                count++;
            }
        }
        for(int i=0;i<shopcars.size();i++){
            if(!isGroupSelected.get(i)){
                isAllSelect = false;
                break;
            }
        }
        if(lastGroupSelectedSize-count==1&&lastGroupSelectedSize==isGroupSelected.size()){
            isAuto = true;//从全选到去掉一个
        }
        lastGroupSelectedSize = count;

        mBalanceCheckBox.setChecked(isAllSelect);

    }

    //刷新视图并计算出总的总的购物车个数及金额
    private void calcItemsAndSize(){

        //刷新视图
        ((BaseExpandableListAdapter)adapter).notifyDataSetChanged();
//        adapter.
        //计算总的items size
        int count = 0;//总选中items数量
        double balance = 0.00;
        for(int i=0;i<isChildSelected.size();i++){
            HashMap<Integer,Boolean> map = isChildSelected.get(i);
            for(int k=0;k<map.size();k++){
                if(map.get(k)){
                    count++;
                    balance = balance + (goodsCarMap.get(i).get(k).getPrice())*(goodsCarMap.get(i).get(k).getNum());
                }
            }
        }

        mTotalAccount.setText(new DecimalFormat("######0.00").format(balance) );
        mTotalAccount1.setText(AppConfig.MONEY_SYMBEL+new DecimalFormat("######0.00").format(balance) );
        mBalance.setText(BaseApplication.getIntstance().getResources().getString(R.string.go_balance)+"("+count+")");
        Log.i("aaa","--count--"+count);
        if(count==0){
            mBalance.setBackgroundResource(R.color.lightest_gray1);
            mBalance.setOnClickListener(null);
        }else{
            mBalance.setBackgroundResource(R.color.title_color);
            mBalance.setOnClickListener(this);
        }
    }


    private void requestData() {
        mEmptyLayout.setErrorType(EmptyLayout.NETWORK_LOADING);

        mBalanceCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean isCheck) {
                Double totalBanlance=0.00;
                totalCount=0;
                Log.i("aaa","--isCheck--"+isCheck);
                if(isCheck){
                    for(int i=0;i<shopcars.size();i++){
                        isGroupSelected.put(i, isCheck);
                    }
                    Set<Object> cityMapSets = goodsCarMap.keySet();
                    int index = 0;
                    for(int i=0;i<cityMapSets.size();i++){
                        HashMap<Integer, Boolean> hashMap = new HashMap<Integer, Boolean>();
                        List<GoodsCar> lists = goodsCarMap.get(i);
                        for(int k=0;k<lists.size();k++){
                            hashMap.put(Integer.valueOf(k), isCheck);
                        }
                        isChildSelected.put(index, hashMap);
                        index++;
                    }

                    for(GoodsCar goodsCar: mgoodsList){
                        totalBanlance += goodsCar.getPrice()*goodsCar.getNum();
                        totalCount++;
                    }
                    mTotalAccount.setText(totalBanlance+"");
                    mTotalAccount1.setText(AppConfig.MONEY_SYMBEL+totalBanlance );
                    mBalance.setText(BaseApplication.getIntstance().getResources().getString(R.string.go_balance)+"("+totalCount+")");
                    lastGroupSelectedSize  = isGroupSelected.size();
                    toInclick();
                }else{
                    if(!isAuto){
                        for(int i=0;i<shopcars.size();i++){
                            isGroupSelected.put(i, isCheck);
                        }
                        Set<Object> cityMapSets = goodsCarMap.keySet();
                        int index = 0;
                        for(int i=0;i<cityMapSets.size();i++){
                            HashMap<Integer, Boolean> hashMap = new HashMap<Integer, Boolean>();
                            List<GoodsCar> lists = goodsCarMap.get(i);
                            for(int k=0;k<lists.size();k++){
                                hashMap.put(Integer.valueOf(k), isCheck);
                            }
                            isChildSelected.put(index, hashMap);
                            index++;
                        }
                        mTotalAccount.setText(0.00+"");
                        mTotalAccount1.setText(AppConfig.MONEY_SYMBEL+0.00 );
                        mBalance.setText(BaseApplication.getIntstance().getResources().getString(R.string.go_balance)+"("+0+")");
                        toClick();
                    }
                    isAuto = false;
                }

                isAuto = false;//重置为手动点击
                //刷新视图
                ((BaseExpandableListAdapter)adapter).notifyDataSetChanged();
            }
        });

        String userId = SPUtils.getStringData(getActivity(), SPUtils.USERID);;

        final OkUtilCallback okUtilCallback =  new OkUtilCallback(mEmptyLayout) {
            @Override
            public void onMyResponse(String response, int id) {
                clearData();
                TLog.log(getFragmentTag(),response);
                ShopcarEntity entity = gson.fromJson(response,ShopcarEntity.class);
                if((!AppConfig.RESULT_OK.equalsIgnoreCase(entity.getResult()))&&entity.getLogin()){
                    mEmptyLayout.setErrorType(EmptyLayout.NODATA);
                    action.setVisibility(View.GONE);
                }else if((!AppConfig.RESULT_OK.equalsIgnoreCase(entity.getResult()))){
                    BaseApplication.getIntstance().showToast(entity.getResult(), Toast.LENGTH_SHORT,0, Gravity.CENTER);
                    mEmptyLayout.setErrorType(EmptyLayout.NODATA);
                    action.setVisibility(View.GONE);
                }else if(entity.getList().size()==0){

                    int num=0;
                    for(Shopcar car : entity.getList()){
                        num = num + car.getGoodsList().size();
                    }
                    TLog.log(getFragmentTag(),"num="+num);
                    BaseApplication.set(AppConfig.SHOPCAR_NUM,num);
                    MainActivity mainActivity = (MainActivity) ShopCatFragment.this.getActivity();
                    mainActivity.initDots();

                    nodataShow();
                }else{
                    action.setVisibility(View.VISIBLE);
                    int num=0;
                    for(Shopcar car : entity.getList()){
                        num = num + car.getGoodsList().size();
                    }
                    TLog.log(getFragmentTag(),"num="+num);
                    BaseApplication.set(AppConfig.SHOPCAR_NUM,num);
                    MainActivity mainActivity = (MainActivity) ShopCatFragment.this.getActivity();
                    mainActivity.initDots();

                    shopcars = entity.getList();
                    for (int i = 0; i < shopcars.size(); i++) {
                        Shopcar shopCar = shopcars.get(i);
                        List<GoodsCar> city = new ArrayList<GoodsCar>();
                        city.addAll(shopCar.getGoodsList());
                        goodsCarMap.put(i, city);
                        mgoodsList.addAll(shopCar.getGoodsList());
                    }
                    if(mgoodsList.size()==0){
                        nodataShow();
                        return;
                    }
                    mNodata.setVisibility(View.GONE);
                    for(int i=0;i<shopcars.size();i++){
                        isGroupSelected.put(i, false);
                    }
                    Set<Object> cityMapSets = goodsCarMap.keySet();
                    int index = 0;
                    for(int i=0;i<cityMapSets.size();i++){
                        HashMap<Integer, Boolean> hashMap = new HashMap<Integer, Boolean>();
                        List<GoodsCar> lists = goodsCarMap.get(i);
                        for(int k=0;k<lists.size();k++){
                            hashMap.put(Integer.valueOf(k), false);
                        }
                        isChildSelected.put(index, hashMap);
                        index++;
                    }

                    listView.setAdapter(adapter);
                    onGroupClickListener = new ExpandableListView.OnGroupClickListener() {

                        @Override
                        public boolean onGroupClick(ExpandableListView parent, View v,
                                                    int groupPosition, long id) {
                            Log.i(getFragmentTag(),"setOnGroupClickListener()");
                            return true;
                        }

                    };
                    listView.setOnGroupClickListener(onGroupClickListener);

                    //设置 属性 GroupIndicator 去掉默认向下的箭头
                    listView.setGroupIndicator(null);

                    for(int i = 0; i < adapter.getGroupCount(); i++){
                        listView.expandGroup(i,false);
                    }
                }
            }

            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
                mEmptyLayout.setErrorType(EmptyLayout.NODATA);
            }
        };
        OKUtilAPI.post(OKUtilAPI.shopList, "userId=" + userId+"&addrId="+AppConfig.CITY_ID, okUtilCallback);
    }

    private void nodataShow() {
        mNodata.setVisibility(View.VISIBLE);
        goShop.getPaint().setFlags(Paint. UNDERLINE_TEXT_FLAG );
        goShop.setOnClickListener(ShopCatFragment.this);
        action.setVisibility(View.GONE);
    }

    /**
     * 重新请求数据将原来的数据清空
     */
    private void clearData() {
        AppConfig.isRefreshShocpar = false;
        shopcars.clear();
        goodsCarMap = new HashMap<Object, List<GoodsCar>>();// 保存二级目录的购物车
        //保存子childbox的选中状态
        isChildSelected = new HashMap<Integer, HashMap<Integer,Boolean>>();
        //保存groupbox的选中状态
        isGroupSelected = new HashMap<Integer, Boolean>();
        mgoodsList.clear();
        isAuto  = false;//全选checkbox是手动点击还是自动变化 默认手动
        lastGroupSelectedSize = 0;
        lastChildSelectedSize = 0;
        selectedCarsId = new HashSet<>();//选中的car id集合
    }


    @Override
    public void onResume() {
        super.onResume();
            requestData();
            mBalance.setBackgroundResource(R.color.lightest_gray1);
            mBalance.setOnClickListener(null);
            mTotalAccount.setText(0.00+"");
             mTotalAccount1.setText(AppConfig.MONEY_SYMBEL+0.00 );
            mBalance.setText(BaseApplication.getIntstance().getResources().getString(R.string.go_balance)+"("+0+")");
         mBalanceCheckBox.setChecked(false);
        action.setOnClickListener(this);

    }

    @Override
    protected int getLayoutId() {
        return R.layout.shopcar_fragment;
    }

}
